package org.doubango.FrCall.Screens;

import java.util.ArrayList;
import java.util.HashMap;

import org.doubango.FrCall.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

public class ManageFriendPage extends Activity {
	private ListView manageFriendList;
	private Button manageFriendDelete;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.manage_friend_page);
		View view = LayoutInflater.from(ManageFriendPage.this).inflate(R.layout.manage_friend_list_item, null);
		manageFriendList = (ListView) findViewById(R.id.manage_friend_list);
		manageFriendDelete =  (Button) view.findViewById(R.id.manage_delete);
		ArrayList<HashMap<String, String>> data = new ArrayList<HashMap<String,String>>();
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("managedfriendname", "王小二");
		map.put("managedfriendid", "ID:15098065");
		data.add(map);
		data.add(map);
		data.add(map);
		data.add(map);
		data.add(map);
		data.add(map);
		data.add(map);
		data.add(map);
		SimpleAdapter adapter = new SimpleAdapter(ManageFriendPage.this, data, R.layout.manage_friend_list_item, new String[]{"managedfriendname", "managedfriendid"}, new int[]{R.id.managed_friend_name, R.id.managed_friend_id});
		manageFriendList.setAdapter(adapter);
		manageFriendDelete.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Toast.makeText(ManageFriendPage.this, "123456", 1000).show();
				
			}
		});

	}
	public void deleteFriend(View v){
		Builder builder = new Builder(ManageFriendPage.this);
		AlertDialog dialog = builder.create();
		dialog.setMessage("确认删除好友？");
		dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确认", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				
			}
		});
		dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				
			}
		});
		dialog.show();
	}
	public void groupFriend(View v){
		Builder builder = new Builder(ManageFriendPage.this);
		AlertDialog dialog1 = builder.create();
		dialog1.setMessage("选择分组");
		View view = LayoutInflater.from(ManageFriendPage.this).inflate(R.layout.dialog_list_group, null);
		ListView listGroup = (ListView) view.findViewById(R.id.dialog_list);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(ManageFriendPage.this, android.R.layout.simple_list_item_1, new String[]{"同学", "家人", "发小", "情人"});
		listGroup.setAdapter(adapter);
		dialog1.setView(view);//addContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
		dialog1.show();
		listGroup.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Builder builder = new Builder(ManageFriendPage.this);
				AlertDialog dialog2 = builder.create();
				dialog2.setMessage("确认将好友放入此分组？");
				dialog2.setButton(DialogInterface.BUTTON_POSITIVE, "确认", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						
					}
				});
				dialog2.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						
					}
				});
				dialog2.show();
			}
			
		});
		
	}
	
	
}
